package com.ayf.payment.game.api.service;

import com.alibaba.fastjson.JSONObject;
import com.ayf.payment.game.api.dto.GamePlayerCashOrderDTO;
import com.ayf.payment.game.api.dto.MerchantAccountOptions;
import com.ayf.payment.game.api.dto.MerchantDTO;
import com.ayf.payment.game.api.dto.MerchantPayOrderDTO;
import com.ayf.payment.game.api.dto.PageInfoDTO;
import com.ayf.payment.game.api.dto.criteria.MerchantPayOrderCriteria;
import com.ayf.payment.game.api.dto.criteria.OrderInfoCriteria;
import com.ayf.payment.game.api.entity.MerchantBatchPayFile;
import com.ayf.payment.game.api.entity.MerchantBatchPayFileFailReason;
import com.ayf.payment.game.api.entity.MerchantPayOrder;
import com.ayf.payment.game.api.excel.CheckUploadPayOrderDTO;
import com.ayf.payment.game.api.excel.UploadPayOrderData;
import com.ayf.payment.game.api.utils.CommonResult;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

public interface MerchantPayOrderService {


	CommonResult createPayOrder(MerchantDTO merchantDTO, MerchantPayOrderDTO payOrderDTO);

	void createAybPayOrder(MerchantDTO merchantDTO, GamePlayerCashOrderDTO dto);

	JSONObject orderQuery(JSONObject inputParam);

	PageInfoDTO<MerchantPayOrderDTO> getMerchantPayOrderListByPage(MerchantPayOrderCriteria merchantPayOrderCriteria);

	MerchantPayOrderDTO getMerchantPayOrderByMerchantOrderNo(String orderId);

	boolean payNotify(String traceId, String requestBody, String sign);

	boolean WanXPayNotify(String traceId, String status, String orderNo);

	boolean LongBaoPayNotify(String traceId, String status, String orderNo, String desc);

	boolean ZhuoFuTongPayNotify(String traceId, String status, String orderNo, String desc);

	int getTotalCount(MerchantPayOrderDTO merchantPayOrderQueryParam);

	List<MerchantPayOrderDTO> getProcessingMerchantPayOrderList(MerchantPayOrderDTO merchantPayOrderQueryParam);

	void updateMerchantPayOrder(MerchantPayOrderDTO dto);

	void changeMerchantAccountAmt(MerchantAccountOptions merchantAccountOptions, String merchantOrderNo, String businessFlag);

	/**
	 * 查询商户代付汇总信息
	 *
	 * @param cri
	 * @return
	 */
	Map<Integer, Map<String, Object>> selectSumPay(OrderInfoCriteria cri);

	/**
	 * 校检批量代付数据
	 *
	 * @param merchantId
	 * @param batchPayFileId
	 * @param dataList
	 * @return
	 */
	CheckUploadPayOrderDTO checkData(Integer merchantId, String batchPayFileId, List<UploadPayOrderData> dataList);

	/**
	 * 批量添加代付数据
	 *
	 * @param batchNo
	 * @param successList
	 * @param failList
	 * @param merchantBatchPayFile
	 * @return
	 */
	@Transactional
	boolean bathAddPay(String batchNo, List<MerchantPayOrder> successList,
	                   List<MerchantBatchPayFileFailReason> failList, MerchantBatchPayFile merchantBatchPayFile);

	/**
	 * 添加
	 *
	 * @param merchantBatchPayFile
	 * @return
	 */
	boolean add(MerchantBatchPayFile merchantBatchPayFile);

	List<MerchantPayOrderDTO> selectBatchPayInfo(Integer status);

	boolean createBathPayOrder(MerchantPayOrderDTO payOrderDTO);

	boolean QiYiPayNotify(String traceId, String status, String orderNo, String channelOrderNo);

	boolean WanWPayNotify(String traceId, Map<String, String> reqParmMap);

	MerchantPayOrderDTO getMerchantPayOrderByChannelOrderNo(String channelOrderNo);

	boolean XingYouPayNotify(String traceId, String status, String orderNo);

	boolean YouKaPayNotify(String traceId, String status, String orderNo, String channelSign, String amount);

	boolean HuanDongPayNotify(String traceId, String status, String orderNo, String channelOrderNo, Map<String, String> signMap, String channelSign);

	boolean qcjhPayNotify(String traceId, Map<String, String> reqParmMap);

	boolean huYuPayNotify(String traceId, Map<String, String> reqParmMap);

	/**
	 * 更新爱游宝代付结果
	 *
	 * @author lch
	 * @date 2021/12/10
	 */
	void refresh();

	/**
	 * 更新单个爱游宝代付结果
	 *
	 * @author lch
	 * @date 2021/12/10
	 */
	void refreshOne(MerchantPayOrder order);

	/**
	 * 根据状态获取数组
	 *
	 * @author lch
	 * @date 2021/12/10
	 */
	List<MerchantPayOrder> listByStatus(Integer status);

	List<MerchantPayOrder> listByChannelAndStatusInRecent7Days(String channelCode, Integer status);

	boolean faKaPayNotify(String traceId, Map<String, String> reqParmMap);

	boolean sky98PayNotify(String traceId, Map<String, String> reqParmMap);

}
